//
//  ZLBurnAfterReadingAttachment.m
//  ZLYoYoIM_Example
//
//  Created by 赵磊 on 2021/1/20.
//  Copyright © 2021 itzhaolei. All rights reserved.
//

#import "ZLAttachment.h"
#import "ZLSessionCustomTypeHeader.h"

@implementation ZLAttachment

- (NSString *)encodeAttachment{
    NSString *urlKey = [self.type intValue] != ZLSessionCustomTypeBurnAfterReading ? @"urlkey" : @"url";
    NSDictionary *dict = @{@"data":@{urlKey:self.url},@"type":self.type};
    NSData *data = [NSJSONSerialization dataWithJSONObject:dict options:0 error:nil];
    NSString *encodeString = @"";
    if (data) {
        encodeString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    }
    return encodeString;
}

#pragma mark - Getter
- (NSString *)url{
    if (!_url) {
        _url = @"";
    }
    return _url;
}

- (NSString *)type{
    if (!_type) {
        _type = @"0";
    }
    return _type;
}

@end
